package terra.model.object.action;

import terra.model.object.ai.AbstractAI;
import terra.model.object.interfaces.Attackable;
import terra.model.object.interfaces.Attacker;

public class ActionAttack extends AbstractAction {

	private static final long serialVersionUID = -3857824218204807353L;
	int time;
	Attackable target;

	public ActionAttack(AbstractAI ai, Attackable target, int time) {
		super(AbstractAI.ACTION_ATTACK, ai);
		this.target = target;
		this.time = time;
	}

	@Override
	public void update(int delta) {
		time -= delta;
		if (time <= 0) {
			target.onHit((Attacker) ai.getOwner(),
					((Attacker) (ai.getOwner())).getDamage());
			end();
		}
	}

}
